package com.jodinfo.outmirror.api.task.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hero.core.entity.ResponseEntity;
import com.jodinfo.outmirror.api.reportaccessstorage.service.ReportAccessStorageBizService;
import com.jodinfo.outmirror.api.reportinventoryanalyze.service.ReportInventoryAnalyzeBizService;
import com.jodinfo.outmirror.api.reportinventorysummary.service.ReportInventorySummaryBizService;
import com.jodinfo.outmirror.api.reportlose.service.ReportLoseBizService;
import com.jodinfo.outmirror.api.reportrepair.service.ReportRepairBizService;
import com.taobao.ad.easyschedule.dataobject.JobResult;
import com.taobao.ad.easyschedule.executor.HttpJobExecutor;

@Controller
@RequestMapping(value="DymcformTaskAdmin")
public class TaskController {
	
	@Resource(name = "reportRepairBizService")
	private ReportRepairBizService reportRepairBizService;
	@Resource(name = "reportLoseBizService")
	private ReportLoseBizService reportLoseBizService;
	@Resource(name = "reportAccessStorageBizService")
	private ReportAccessStorageBizService reportAccessStorageBizService;
	@Resource(name = "reportInventoryAnalyzeBizService")
	private ReportInventoryAnalyzeBizService reportInventoryAnalyzeBizService;
	@Resource(name = "reportInventorySummaryBizService")
	private ReportInventorySummaryBizService reportInventorySummaryBizService;
	
	@RequestMapping(value = "/reportRepairTask")
	@ResponseBody
	public JobResult reportRepairTask(HttpServletRequest request) throws Exception {
		JobResult result = HttpJobExecutor.getInstance().execute(request, reportRepairBizService);
		return result;
	}
	@RequestMapping(value = "/testRepairTask")
	@ResponseBody
	public ResponseEntity testRepairTask(HttpServletRequest request) throws Exception {
		String date = request.getParameter("date");
		return reportRepairBizService.testTask(date); 
	}
	
	@RequestMapping(value = "/reportLoseTask")
	@ResponseBody
	public JobResult reportLoseTask(HttpServletRequest request) throws Exception {
		JobResult result = HttpJobExecutor.getInstance().execute(request, reportLoseBizService);
		return result;
	}
	@RequestMapping(value = "/testLoseTask")
	@ResponseBody
	public ResponseEntity testLoseTask(HttpServletRequest request) throws Exception {
		String date = request.getParameter("date");
		return reportLoseBizService.testTask(date);
	}
	@RequestMapping(value = "/reportAccessStorageTask")
	@ResponseBody
	public JobResult reportAccessStorageTask(HttpServletRequest request) throws Exception {
		JobResult result = HttpJobExecutor.getInstance().execute(request, reportAccessStorageBizService);
		return result;
	}
	@RequestMapping(value = "/testAccessStorageTask")
	@ResponseBody
	public ResponseEntity testAccessStorageTask(HttpServletRequest request) throws Exception {
		String date = request.getParameter("date");
		return reportAccessStorageBizService.testTask(date);
	}
	@RequestMapping(value = "/reportInventoryAnalyzeTask")
	@ResponseBody
	public JobResult reportInventoryAnalyzeTask(HttpServletRequest request) throws Exception {
		JobResult result = HttpJobExecutor.getInstance().execute(request, reportInventoryAnalyzeBizService);
		return result;
	}
	@RequestMapping(value = "/testInventoryAnalyzeTask")
	@ResponseBody
	public ResponseEntity testInventoryAnalyzeTask(HttpServletRequest request) throws Exception {
		String date = request.getParameter("date");
		return reportInventoryAnalyzeBizService.testTask(date); 
	}
	@RequestMapping(value = "/reportInventorySummaryTask")
	@ResponseBody
	public JobResult reportInventorySummaryTask(HttpServletRequest request) throws Exception {
		JobResult result = HttpJobExecutor.getInstance().execute(request, reportInventorySummaryBizService);
		return result;
	}
	@RequestMapping(value = "/testInventorySummaryTask")
	@ResponseBody
	public ResponseEntity testInventorySummaryTask(HttpServletRequest request) throws Exception {
		String date = request.getParameter("date");
		return reportInventorySummaryBizService.testTask(date); 
	}
}
